import json
from Config.cfg import cfg
from Lib.Base.base_request import request


def get_token():
    '''
    获取token参数
    '''
    url = f"{cfg.host_token}"
    json_data = {}

    json_data["userName"] = f"{cfg.userName}"
    json_data["password"] = f"{cfg.passWord}"
    # header = {'content-type':'application/json;charset=utf-8'}
    res = request.send_post(url, json_data)
    res = json.loads(res)

    token = res.get('data').get('users').get('accessToken')

    res_token = "Bearer " + token
    header = {"Authorization": res_token}

    return header


if __name__ == "__main__":
    res_token = get_token()
    print(res_token)
    print(type(res_token))
